Computational methods in statistics

Topics: cross validation, david fletcher powell formula, quasi newton, arma model, permutation test, monte carlo bias, balanced bootstrap, u-statistic, bootstrap aggregating (bagging), bootstrap t, bootstrap based bias correction, filtering problem, parametric bootstrap, markov model, hidden markov model, cauchy, expectation maximiaztion, pivotal quanitity, exhaustive bootstrap,

What is the difference between time series and

Difference between nonsequential monte carlo, sequential monte carlo, particle filters

1 Prerequisites

2 Iterative methods

2.1 Newton-like methods

2.2 Other methods

2.3 Feature selection

2.4 EM algorithm

3 Monte Carlo (MC)

Exact Monte Carlo

Variance reduction techniques

Approximate Monte Carlo simulation

4 Markov chain Monte Carlo (MCMC)

5 Resampling

Bootstrapping

Sequence convergent in probability

\[{{{\underset{{n \to{} \infty}}{\operatorname{Lim}} {{\operatorname{\mathbb{P}} {{\left[{{{{\lvert{} {X}_{n} - X \rvert}}} < \epsilon}\right]}}}}}} = 1}\]

Sequence almost surely convergent

Sequence convergent in distribution

Weak law of large numbers

Strong law of large numbers

Central limit theorem

Rao–Blackwell

Let \(S\) be an estimator of \(\theta\) and \(T\) a sufficient statistic for \(\theta\). Then \({{\operatorname{\mathbb{E}} {{\left[{S \vert{} T}\right]}}}}\) is a better estimator of \(\theta\) (smaller or equal variance).

Negative covariance cancels variance of sum

Ease of implementation of a method

A method may be difficult to implement

High complexity methods are prone to bugs and mistakes, which furthermore may be hard to even notice.

Robustness of a method

Heuristic

A heuristic is an informal rule of thumb that is followed in a method. Although not grounded in theory, the rule is based on some intuition or insight that makes us hope that following it will lead us to a valid optimization procedure.

Heuristic method

A heuristic method is an optimization method that follows a heuristic rule.

Bisection method

Convergence criterion

of a method

Absolute convergence criterion

Relative convergence criterion

Optimization problem

Bolzano’s theorem

Markov chain

Markov property

Transition probability matrix

Stationary distribution

Irreducible Markov chain

Every state is reachable in finite steps.

Periodic Markov chain

Some states can only be reached in regularly spaced intervals.

Period of Markov chain state

The period of a Markov chain state is the

Aperiodic Markov chain

A Markov chain is aperiodic if every state has period 1.

Ergodic theorem

If X_n is an irreducible and aperiodic Markov chain with stationary distribution \(\pi\), then \({X}_{n}\) converges in distribution to \(\pi\), and \[{\frac{1}{n} {\sum}_{t} h({X}_{t}) \to{} {E}_{\pi}{} h(X)}\] almost surely.

Independence chain

Trivially a Markov chain.

Iterative method

An iterative method is a method that takes a initial starting point \({{x}^{(0)}}_{i}\) and computes the next values \({x}^{(1)}\), \({x}^{(2)}\) and so on, which are hoped to be increasingly better approximate solutions to the problem. This is done until reaching a stopping criterion. Common stopping criteria is number of steps or change in estimate is less than a threshold quantity.

Convergence

\[{ \frac{{{{\lvert{} {{x}_{k+1} - L} \rvert}}}}{{{{{\lvert{} {x}_{k} - L \rvert}}}}^{q}}}\]

Rate of convergence of an iterative method

Order of convergence of an iterative method

Secant method

The secant method is a root finding method. The secant method uses \({x}_{n-1}\) and \({x}_{n}\) to draw a line between two points that crudely approximates the function. We then solve for where the line crosses the x-axis, which is then the next \({x}_{n+1}\).

Gradient ascent

Gradient ascent computes the gradient at \({x}^{(t)}\). It will point in the direction of steepest ascent. We follow this direction to find the next \({x}^{(t+1)}\). Terminates when the gradient is \(0\) or negligibly small.

Restarting methods

Restarting a method from several initial points is a guard against only exploring local maxima.
But this is not necessary if the method is concave.

Newton’s method

Gauß–Newton

Newton-like method

In Newton-like methods the Hessian is replaced by an approximation.

This is because the Hessian is expensive to compute, and there are many cheaper alternatives that can perform well.

Hessian stand-in in a Newton-like method

Fisher scoring

Fisher scoring is a Newton-like method for maximizing a likelihood function where the Hessian stand-in is the negative Fisher information matrix, replacing the negative observed information \({-{\sum}_{i} {{\partial}_{\theta}}^{2} \ell(\theta\vert{x}_{i})}\).

Backtracking

A backtracking method checks if the new value is satisfactory. If not, the method returns to the last step and tries to optimize using a different configuration.

Backtracking Newton-like method

In this method, we check if the score of the imminent \({x}^{a(i+1)}\) is greater than the previous score before it is accepted. If it is not accepted, we consider smaller and smaller steps towards \({x}^{(i+1)}\), until the score is improved.

Quasi-Newton method

A quasi-Newton method is a Newton-like method that uses the Hessian stand-in \({M}^{(t)}\) to generate the next step’s \({M}^{(t+1)}\). The Hessian stand-in is updated, rather than computed from scratch.

Davidon’s update method

Davidon’s update method is a quasi-Newton method. It uses the gradient at \({x}^{(t)}\) and \({x}^{(t+1)}\) to compute

DFP

Davidon–Fletcher–Powell formula is a quasi-Newton method

BFGS update

Broyden–Fletcher–Goldfarb–Shanno algorithm is a quasi-Newton method

Quasi-Newton methods properties

...

Simulated annealing

Nelder–Mead method

In \(n\)-dimensional space, use \(n+1\) vertices. The Nelder–Mead method gradually moves the simplex spanned by these vertices toward a maximum.

Nonlinear Gauß–Seidel iteration

Genetic algorithm

A variable selection method.

Tabu algorithm

EM algorithm

\[{f \to{} X \to{} Y = h(X)}\]
Let \(\mathcal{M}\) be a model with parameters \(\Theta\), let \({\ell(\theta\vertX)}\) be the log-likelihood function of the data.
What if some data is missing? Let \(Y\) be the available data and \(Z\) the missing data. The EM algorithm uses the available data Y and the immediate estimate \(\theta\). E-step: we have the log-likelihood which depends on \(\theta\), \(Y\) and \(Z\). We have \(Y\) and an approximation of \(\theta\), but not \(Z\). In this step we sum out \(Z\) to create a function \(Q\) of \(\theta\) and \(Y\) only. M-step: Maximize the function \(Q\) from the previous step to find a new estimate of the parameter \(\theta\).
Start with an estimate of \(\theta\).

    EM algorithm for latent variables

    \[{f \to{} X = (Y, Z) \to{} Y}\]
    When there is a set of observed variables \({Y}_{{1:n}}\) and a set of unobserved/latent variables \({Z}_{{1:n}}\), the EM algorithm can be applied as follows.


      There is an alternative way to see this algorithm. Once we compute \(X\), we also have

        EM for exponential distributions

        For exponential distributions the EM algorithm...

        Convergence

        ...

        Order of convergence

        ...

        Missing information principle

        The missing information principle states that the observed information is equal to the complete information minus the unobserved information.

        SEM (Supplemented EM) algortithm

        A modification of the E step in the EM algorithm. At each step, we try to compute the unobserved information as well.

        Bootstrapping EM variance

        By resampling, for example bootstrap, we can run the EM algorithm several times for these pseudosamples. By these pseudosamples we can find a bootstrap estimate for the variance.

        Monte-Carlo estimated EM algorithm (MCEM)

        Calculating the expectation in \(Q\) could be difficult. This modification uses Monte Carlo to approximate the expectation.

        Expectation conditional maximization (ECM) algorithm

        Conditional maximization: place a constraint on the maximization step.

        EM gradient method

        Replace the M-step with a single step with Newton’s method. Instead of maximizing, perform one step of Newton’s method. \[{{\theta}^{(t+1)} = {\theta}^{(t)} - \frac{{Q'(\theta\vert{\theta}^{(t)})}}{{Q''(\theta\vert{\theta}^{(t)})}}}\]

        Quasi-Newton acceleration

        Modify the EM gradient to use a quasi-Newton method instead of a step of Newton’s method.

        Aitken acceleration

        \[{{\theta}^{(t+1)} = {\theta}^{(t)} - \frac{.}{{\ell''{\left(#1\right)}}}}\]

        Monte Carlo (MC)

        Monte Carlo is the usage of random samples to

          Monte Carlo method

          A Monte Carlo method uses generated random samples (often from a uniform distribution) to produce random samples from a more complicated distribution.
          Sometimes it is infeasible to integrate or normalize a distribution. This also means that we do not have access to its distribution nor likelihood function.

          Monte Carlo simulation

          Monte Carlo simulation uses random sampling from a simple distribution to create a sample from a more complex distribution.

          Monte Carlo estimation

          Monte Carlo estimation is a method for estimating a parameter of a distribution. Monte Carlo simulation is used to produce a sample from

          Monte Carlo estimate

          Let \(f\) be a distribution that it is difficult to sample from. Use a Monte Carlo simulation method to generate a sample \({\mathbf{X}}\) from \(f\).

          Monte Carlo integration

          Monte Carlo integration \(x\)

          Exact and approximate simulation

          In exact Monte Carlo samples are generated from \(f\) exactly, while in approximate Monte Carlo samples are generated from an approximation of \(f\), possibly because it is too hard or time consuming to sample exactly.

          Inverse CDF sampling

          Inverse CDF sampling is a Monte Carlo sampling method. In inverse CDF sampling, random values are sampled from a uniform distribution on \({{\left[0..1\right]}}\). \({F}^{-1}\) is then applied to the sample values to obtain a sample over \(f\).
          This means that a sample from any distribution can be obtained by sampling from a uniform distribution under the hood and knowing \({F}^{-1}\). Advantages of this is that implementing a uniform distribution sampler is simpler than most distributions.

          Uniform grid interpolation sampling

          If \(F\) is available but not \({F}^{-1}\), this sampling method can approximate the inverse by interpolation.
          Overlay a grid of points \({{\left\{{{x}_{1}, {x}_{2}, \dots, {x}_{g}}\right\}}}\) on the support of \(F\). Compute \({{\left\{{{F}_{1}, {F}_{2}, \dots, {F}_{g}}\right\}}}\) and use this to interpolate the values from a random sample from a uniform distribution to obtain a sample from \(f\).

          Uniform rejection sampling

          ..

          Rejection sampling

          Rejection sampling (accept-reject sampling) is a Monte Carlo sampling method that generalizes the idea of uniform rejection sampling.

          Sample size to error

          The Monte Carlo error is \({\sqrt{{{\operatorname{Var} {\frac{1}{N} {\sum}_{i} h({X}_{i})}}}} = \sqrt{\frac{{\sigma}^{2}}{n}}}\).
          A linear improvement in the Monte Carlo estimator requires a quadratic increase in the number of samples: To get a twice as good estimator (halve the variance), the number of samples must be quadrupled. To get an \(n\) times better estimator, the number of samples must be \({n}^{2}\).

          Squeezed rejection sampling

          Adaptive rejection sampling

          The envelope and squeezing function are iteratively refined every step as well.

          Importance sampling

          Importance sampling A sampling method where we sample a weighted sample. This can lower the variance.

          Variance reduction techniques

          These are techniques that can be applied to the components in Monte Carlo simulations; this is done in hope of reducing the sample variance.

          Variance reduction by importance sampling

          The crude Monte Carlo estimator has variance

          Antithetic variates

          Antithetic sampling is a modification of Monte Carlo sampling. If a

          Antithetic variates on monotonic function

          Let \(h\) be monotonic.
          One way to implement antithetic sampling is to exploit the fact that \(h\) is monotonic. We can easily generate negatively correlated uniform variables, and monotonicity preserves this negative correlation when applied to the variables.
          Sample from \(U\) to get \({X}_{i}\) and \({{Y}_{i} = 1 - {X}_{i}}\), two opposite values on \({{\left[0..1\right]}}\). \({X}_{i}\) and \({Y}_{i}\) are negatively correlated, and since \(h\) is monotonic, \({h({X}_{i})}\) and \({h({Y}_{i})}\) are as well.
          The Monte Carlo estimator is \({{\hat\mu}_{\text{AS}} = {\sum}_{i} \frac{h(X_i) + h(Y_i)}{2}}\).

          Control variates

          Control variates: the offset in a known quantity is correlated with the offset in the unknown quantity.

          Importance sampling with control variates

          Implements control variates for importance sampling by using the weights as a control variate.

          Rao–Blackwellization

          By the Rao–Blackwell theorem, conditioning an estimator of \(\theta\) on a sufficient statistic for \(\theta\) returns an estimator with smaller variance.
          We have the Monte Carlo estimate \({\frac{1}{n} {\sum}_{i} h({X}_{i})}\) of \({{\operatorname{\mathbb{E}} f(X)}}\).

          Approximate simulation

          When f is complicated or expensive to evaluate,

          Sampling importance resampling (SIR)

          Wh

          A method where instead of sampling from f, we sample from an envelope g of f.

          We use the weighted sample

          Sequential Monte Carlo

          In sequential Monte Carlo the sample points themselves are generated in several steps.
          Sequential Monte Carlo is useful when the sample points are high dimensional or sequences. The hope is that there is some structure within the sample points that makes them easier to sample stepwise. For example, a Markov chain or time series.


          A sequential Monte Carlo method generates for each t a sample of time series.

          A sequential Monte Carlo method generates a sample in step \(i\), and uses this sample to generate a sample in step \(i + 1\).

          This method is cheap to update: we simply append a new observation to the time series and update the weigth.

          Sequential Monte Carlo

          In sequential Monte Carlo the sample points themselves are generated in several steps.
          Sequential Monte Carlo is useful when the sample points are high dimensional or sequences. The hope is that there is some structure within the sample points that makes them easier to sample stepwise. For example, a Markov chain or time series.


          A sequential Monte Carlo method generates for each t a sample of time series.

          A sequential Monte Carlo method generates a sample in step \(i\), and uses this sample to generate a sample in step \(i + 1\).

          This method is cheap to update: we simply append a new observation to the time series and update the weigth.

          Discarding old values

          If we are only interested in the most recent estimates, for example if the estimation is done and updated in real-time as new observations come in, old values can be deleted safely.

          Sequential importance sampling (SIS)

          The sequential version of importance sampling.

          Sequential importance sampling

          1) Generate a weighted sample of n elements.

          2) Loop:

          Sequential importance sampling for Markov chain

          When the process is a Markov process, sequential importance sampling is simplified.

          Weight degeneracy

          As t increases, the weigths in SIS become degenerate: a few weights are far greater than all the others.

          Effective sample size

          The effective sampling size should be \(n\) when the weights are equal and low when the weights are degenerate.
          \[\frac{1}{{{\sum}_{i} ({w}_{i}{)}^{2}}}\]

          SMC with rejuvenation

          After running a sequential method for some time the weights will degenerate: most of the mass will accumulate in a few weights.
          This can be fixed by regularly rejuvenating the sequences, filtering out those sequences that have to small weights. These methods are called particle filters.

          Adaptive importance sampling

          In this method the envelope is updated at each t.

          Particle filter

          A particle filter is a sequential Monte Carlo method that has n sequences, X^(1), ..., X^(n). At each step a new observation is generated for and appended to each of the sequences.

          At each step, a weighted sample is drawn. Then a resample is performed; this will prioritize.

          This causes particles with low weights to be discarded, while high weight particles are replicated. The sampling step introduces variation between the particles.

          Running the algorithm many steps should make the particles converge.

          fn particle_filter(initial_vals, t) {
            n <- initial_vals.len()
            seqs <- []
            for i in 0..n {
              seqs[i] <- [initial_vals[i]]
            }
            for s in 0..t {
          
            }
          }
          

          Particle of a particle filter

          Sequential importance resampling

          (Not to be confused for sampling importance resampling)
          Modifies sequential importance sampling. During the steps of sequential importance sampling, it is checked if the weights have become degenerate, for example by calculating the effective sample size and checking if it has fallen below a threshold. If so, the sequences generated so far are resampled according to their weights, and the method continues with those sequences. Their weights are reset to \(\frac{1}{n}\).

          Sampling importance resampling & sequential importance resampling

          We can see the sampling importance resampling algorithm as the sequential importance resampling method where only the initial step of sampling and resampling is performed.

          Bootstrap filter

          A bootstrap filter is a particle filter that resamples with replacement the sequences at the end of each step. The resampled sequences replaces the original ones, and their weights are set to \(\frac{1}{n}\).

          MCMC method

          Given a distribution f, the goal of the MCMC method is to create a Markov chain with stationary distribution f. We can then use the chain to draw a sample.

          Burn-in period

          The burn-in period

          Metropolis–Hastings

          In Metropolis–Hastings, a proposal distribution is used to draw. We

          Metropolis–Hastings with symmetric proposal

          When the proposal is symmetric, for example when it is a normal distribution, then the MH ratio reduces to \(\frac{f(x^*)}{{f({x}^{(t)})}}\)

          Proposal distribution

          Metropolis–Hastings ratio

          Gibbs sampling

          In Gibbs sampling, we assume that we can sa

          Update reordering in Gibbs sampling

          ...

          Gibbs and MH sampling

          ...

          Hybrid Gibbs sampling

          Gibbs sampling where in each cycle we update blocks of variables in different ways.

          Griddy–Gibbs sampler

          ...

          MCMC questions

          ...

          MCMC performance diagnostics

          Graphical diagnostics: autocorrelation plots, trace plots

          burn-in, run length

          effective sample size

          Gelman–Rubin statistic

          The Gelman–Rubin statistic is a comparison of between-chains and within-chain variance. \[\frac{{\frac{L-1}{L} W + \frac{1}{L} B}}{W}\]
          If the result is bad, increase the burn-in period and the length of the chain.

          Resampling

          Let X be a sample. A resampling method generates pseudosamples using only X.

          Resampling advantages

          Allows us to get an approximate distribution for X without making any distributional assumptions.

          Resampling intuition

          Let \({{\left{1,2,3,4,5,6\right}}}\) be a sample. Ignoring order, there is one way we can draw the bootstrap sample \({\left(#1\right)}\) and many ways we can draw \({\left(#1\right)}\). Repeating this several times generates a histogram of T(X). We use this histogram to find bootstrap estimators of T(X), such as the bootstrap mean, median and variance.

          Bootstrapping


          A bootstrapping method is a resampling method that produces bootstrap pseudosamples.

          Jackknife

          Cross-validation

          Permutation test

          A permutation test is a test for the null hypothesis: both distributions are the same.

          Bootstrapping


          A bootstrapping method is a resampling method that produces bootstrap pseudosamples.

          The bootstrap principle

          The bootstrap principle: equate the (exact) bootstrapping distribution of a sample \(\mathbf{x}\) to the distribution of \(X\).

          Pseudosample

          Exact bootstrapping

          In exhaustive bootstrapping, we iterate over all possible bootstrap samples, evaluate \(T(X)\) and generate the exact histogram for \(T(X)\).

          However, the number of possible bootstrap samples, \({n}^{n}\), quickly blows up, so this method is infeasible; instead, we approximate by randomly sampling for example \(10 000\) bootstrap samples.

          Nonparametric bootstrapping

          Regular bootstrapping. Resample with replacement

          Parametric bootstrapping

          Let \({f(x \vert{} \theta)}\) be a parametric distribution and \(X\) a sample from \(f\).

          In parametric bootstrapping, we use the available sample to estimate the parameter of the distribution, and then draw pseudosamples from the estimated distribution.

          We can now draw pseudo-samples from \({f(x \vert{} \theta)}\).

          Regression bootstrapping

          Method for bootstrapping a realized regression model.

          Residual bootstrapping

          Bootstrapping a regression model we want to find the distribution of \(\beta\), the regression parameter.

          Paired bootstrap

          Bootstrap bias correction

          ...

          Bootstrap bias estimate

          The bootstrap estimate of the bias of \(\theta\).

          Bias-corrected bootstrap estimate

          \(\hat\theta\)

          Let \(X\) be a var and \(\hat{X}\) be an est of \(X\).

          Percentile method

          The percentile method is a method for constructing a confidence interval for \(\theta\) based on the histogram for \(\hat\theta\) produced by bootstrapping.

          Percentile method hypothesis test

          A test based on the percentile method. The test rejects the null hypothesis \({{H}_{O} = {x}_{0}}\) if \({x}_{0}\) is outside the bootstrap confidence interval.

          Pivoting method

          Pivoting is a method to produce confidence intervals through using a pivotal quantity.

          Pivotal quantity of \(\theta\)

          A pivotal statistic is a statistic whose distribution is always the same for all values of \(\theta\).

          These statistics we cannot actually compute, because they depend on the unknown parameter value. But by doing some algrebra, they allow us to easily create confidence intervals and tests.

          Accelerated bias-corrected percentile method

          A pivoting method for generating a confidence interval for a parameter, but where the bias of the endpoints of the confidence interval are corrected.

          More robust than simple percentile method:

          We find functions and parameters to transform the bias to a standard normal distributed. The bootstrap principle gives the bootstrap estimator a StdN distribution.

          We can now use the quantiles of the StdN

          Bootstrap t

          ...

          Empirical variance stabilization

          Nested bootstrap

          ...

          Bias reducing bootstrap

          Bias reducing bootstrap methods

          Balanced bootstrap

          Balanced bootstrap is a way to bootstrap without introducing any bias. We do this by making sure that

          1) Concatenate B copies of the sample. This ensures that the frequency of all sample elements are preserved. 2) Randomly permute the concatenation. 3) Read off the B bootstrap samples.

          Antithetic bootstrap

          Antithetic bootstrapping is a way to eliminate bias.

          Impose ordering on the sample by ordering statistics. When drawing a sample, also draw a sample from the reversed indices. This creates two negatively correlated pseudosamples.

          Bootstrapping dependent data

          If the data is dependent, bootstrapping cannot be performed normally.

          Bootstrapping time series

          Model based residual bootstrap

          If we know the model, we can resample residuals. We will then get a pseudosample this way.

          When bootstrapping time series, we must try to preserve autocorrelation.

          Nonmoving block bootstrap

          To preserve the autocorrelation between observations, we sample blocks of observations from the sample in place of singular observations.

          Moving block bootstrap

          All sequences of k consequtive observations are considered a block. Thus we can start from any index (except near the end).

          Blocks of blocks bootstrap

          This is a nested form of block bootstrapping. We perform block bootstrapping on the original sample, then we

          Bootstrap performance

          ...

          Incomplete
          Complete
          2024-Jul-31 (46 hours ago)
          2024-Jul-31 (46 hours ago)
          2024-Jul-31 (46 hours ago)
          2024-Jul-31 (46 hours ago)